Random = Mock.Random


function getOrder(){

    let pet_list = []

    for(let i = 0; i < 5; i++){
        let pet = Mock.mock({
            'image' : Random.image(),
            'pet_name' : Random.cname(),
            'price' : Random.float(10,1000,2,2),
            'number' : Random.integer(1,10)
        })

        pet_list.push(pet)
    }

    let data = Mock.mock({
        'order_number' : /O[0-9]{11}/,
        'date' : Random.datetime(),
        'pet_list':pet_list,
        'total_price': Random.float(100,1000,2,2)
    })

    let json = {
        data,
        code : 200,
        msg: '获取成功'
    }

    return json
}

function getCORes(){
    let json = {
        code : 200,
        msg: '下单成功'
    }

    return json
}

Mock.mock("http://localhost/order.php", 'post', getOrder)

Mock.mock("http://localhost/commit_order.php", 'post', getCORes())